const mysql = require('mysql');
const { MYSQL_CONF } = require('../conf/db');

const con = mysql.createConnection(MYSQL_CONF);

//开始连接
con.connect();

//执行sql
function exec(sql) {
  return new Promise((resolve, reject) => {
    con.query(sql, (err, data) => {
      if (err) {
        reject(err);
      }
      resolve(data);
    })
  })
}

module.exports = {
  exec
};
